package com.itheima.socket.tcp.demo08;

import java.io.*;
import java.net.ServerSocket;
import java.net.Socket;

public class ServerDemo08 {

    public static void main(String[] args) throws IOException {

        ServerSocket serverSocket = new ServerSocket(9696);
        Socket socket = serverSocket.accept();
        InputStream inputStream = socket.getInputStream();
        BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
        BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter("D:\\2019.7.30heima\\1.txt"));
        String line = null;
        while ((line = bufferedReader.readLine()) != null){
            bufferedWriter.write(line);
            bufferedWriter.newLine();
            bufferedWriter.flush();
        }
        socket.close();
        serverSocket.close();
    }
}
